#include "widget.h"
#include "./ui_widget.h"
#include <QPushButton>
#include <QGridLayout>
#include "server.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    QGridLayout* layout = new QGridLayout;
    this->setLayout(layout);

    QPushButton* button1 = new QPushButton;
    button1->setText("sendTextNotify");
    connect(button1,&QPushButton::clicked,this,[=]()
    {
        LOG()<<"发送sendTextNotify信号";
        emit WebSocketServer::getInstance()->sendTextNotify();
    });
    layout->addWidget(button1);


    QPushButton* button2 = new QPushButton;
    button2->setText("sendImageNotify");
    connect(button2,&QPushButton::clicked,this,[=]()
    {
        LOG()<<"sendImageNotify";
        emit WebSocketServer::getInstance()->sendImageNotify();
    });
    layout->addWidget(button2);


    QPushButton* button3 = new QPushButton;
    button3->setText("sendFileNotify");
    connect(button3,&QPushButton::clicked,this,[=]()
    {
        LOG()<<"sendFileNotify";
        emit WebSocketServer::getInstance()->sendFileNotify();
    });
    layout->addWidget(button3);


    QPushButton* button4 = new QPushButton;
    button4->setText("sendSpeechNotify");
    connect(button4,&QPushButton::clicked,this,[=]()
    {
        LOG()<<"sendSpeechNotify";
        emit WebSocketServer::getInstance()->sendSpeechNotify();
    });
    layout->addWidget(button4);





    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    LOG()<<"发送sendFriendAddApplyNotify信号";
    emit WebSocketServer::getInstance()->sendFriendAddApplyNotify();
}


void Widget::on_pushButton_2_clicked()
{
    LOG()<<"发送sendFriendAddApplyProcessNotify信号";
    emit WebSocketServer::getInstance()->sendFriendAddApplyProcessNotify(true);
}


void Widget::on_pushButton_3_clicked()
{
    LOG()<<"发送sendFriendAddApplyProcessNotify信号";
    emit WebSocketServer::getInstance()->sendFriendAddApplyProcessNotify(false);
}


void Widget::on_pushButton_4_clicked()
{
    LOG()<<"发送创建群聊通知";
    emit WebSocketServer::getInstance()->sendCreateSessionNotify(true);
}

